/*给你一个数组 nums ，数组中有 2n 个元素，按 [x1,x2,...,xn,y1,y2,...,yn] 的格式排列。
请你将数组按 [x1,y1,x2,y2,...,xn,yn] 格式重新排列，返回重排后的数组。*/

import java.util.Scanner;

public class Shuffle {
    public static int[] shuffle(int[] nums, int n) {
        int[] res = new int[2 * n];
        for (int i = 0; i < n; i++) {
            res[2 * i] = nums[i];
            res[2 * i + 1] = nums[i + n];
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("输入n: ");
        int n = scanner.nextInt();
        int length = 2 * n;
        int[] nums = new int[length];
        System.out.println("输入 " + length + " 个整数");
        for (int i = 0; i < length; i++) {
            nums[i] = scanner.nextInt();
        }
        int[] res = shuffle(nums, n);
        System.out.println("重新排列后的数组：");
        for (int num :res) {
            System.out.print(num + " ");
        }
        scanner.close();
    }

}
